{% extends 'car_system/base.html' %}

{% block title %}{{ title }} - 汽车数据分析系统{% endblock %}

{% block content %}
<nav aria-label="breadcrumb">
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="{% url 'home' %}">首页</a></li>
        <li class="breadcrumb-item"><a href="{% url 'car_list' %}">汽车数据</a></li>
        <li class="breadcrumb-item active" aria-current="page">{{ title }}</li>
    </ol>
</nav>

<div class="card">
    <div class="card-header bg-primary text-white">
        <h5 class="mb-0">
            {% if form.instance.pk %}
            <i class="fas fa-edit me-2"></i>编辑车型: {{ form.instance.series_name }}
            {% else %}
            <i class="fas fa-plus-circle me-2"></i>添加新车型
            {% endif %}
        </h5>
    </div>
    <div class="card-body">
        <form method="POST">
            {% csrf_token %}
            <div class="row">
                <!-- 基本信息 -->
                <div class="col-md-6">
                    <h5 class="mb-3">基本信息</h5>
                    
                    <div class="mb-3">
                        <label for="{{ form.series_id.id_for_label }}" class="form-label">车系ID</label>
                        {{ form.series_id }}
                        {% if form.series_id.errors %}
                        <div class="text-danger">{{ form.series_id.errors }}</div>
                        {% endif %}
                        <div class="form-text">唯一标识每个车型系列</div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.series_name.id_for_label }}" class="form-label">车系名称</label>
                        {{ form.series_name }}
                        {% if form.series_name.errors %}
                        <div class="text-danger">{{ form.series_name.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.image.id_for_label }}" class="form-label">车型展示图URL</label>
                        {{ form.image }}
                        {% if form.image.errors %}
                        <div class="text-danger">{{ form.image.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.brand_id.id_for_label }}" class="form-label">品牌ID</label>
                        {{ form.brand_id }}
                        {% if form.brand_id.errors %}
                        <div class="text-danger">{{ form.brand_id.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.brand_name.id_for_label }}" class="form-label">品牌名称</label>
                        {{ form.brand_name }}
                        {% if form.brand_name.errors %}
                        <div class="text-danger">{{ form.brand_name.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.sub_brand_id.id_for_label }}" class="form-label">子品牌ID</label>
                        {{ form.sub_brand_id }}
                        {% if form.sub_brand_id.errors %}
                        <div class="text-danger">{{ form.sub_brand_id.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.sub_brand_name.id_for_label }}" class="form-label">子品牌名称</label>
                        {{ form.sub_brand_name }}
                        {% if form.sub_brand_name.errors %}
                        <div class="text-danger">{{ form.sub_brand_name.errors }}</div>
                        {% endif %}
                    </div>
                </div>
                
                <!-- 价格与排名信息 -->
                <div class="col-md-6">
                    <h5 class="mb-3">价格与排名信息</h5>
                    
                    <div class="mb-3">
                        <label for="{{ form.min_price.id_for_label }}" class="form-label">最低指导价（万元）</label>
                        {{ form.min_price }}
                        {% if form.min_price.errors %}
                        <div class="text-danger">{{ form.min_price.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.max_price.id_for_label }}" class="form-label">最高指导价（万元）</label>
                        {{ form.max_price }}
                        {% if form.max_price.errors %}
                        <div class="text-danger">{{ form.max_price.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.price.id_for_label }}" class="form-label">价格区间字符串表示</label>
                        {{ form.price }}
                        {% if form.price.errors %}
                        <div class="text-danger">{{ form.price.errors }}</div>
                        {% endif %}
                        <div class="form-text">例如：49.50-74.00万</div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.dealer_price.id_for_label }}" class="form-label">经销商参考价格</label>
                        {{ form.dealer_price }}
                        {% if form.dealer_price.errors %}
                        <div class="text-danger">{{ form.dealer_price.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3 form-check">
                        {{ form.has_dealer_price }}
                        <label for="{{ form.has_dealer_price.id_for_label }}" class="form-check-label">是否有经销商参考价</label>
                        {% if form.has_dealer_price.errors %}
                        <div class="text-danger">{{ form.has_dealer_price.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.ranks.id_for_label }}" class="form-label">当前排名</label>
                        {{ form.ranks }}
                        {% if form.ranks.errors %}
                        <div class="text-danger">{{ form.ranks.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.last_rank.id_for_label }}" class="form-label">上月排名</label>
                        {{ form.last_rank }}
                        {% if form.last_rank.errors %}
                        <div class="text-danger">{{ form.last_rank.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3 form-check">
                        {{ form.show_trend }}
                        <label for="{{ form.show_trend.id_for_label }}" class="form-check-label">是否显示排名趋势图标</label>
                        {% if form.show_trend.errors %}
                        <div class="text-danger">{{ form.show_trend.errors }}</div>
                        {% endif %}
                    </div>
                </div>
                
                <!-- 销量与统计信息 -->
                <div class="col-md-12 mt-4">
                    <h5 class="mb-3">销量与统计信息</h5>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="{{ form.count.id_for_label }}" class="form-label">月销量（台）</label>
                                {{ form.count }}
                                {% if form.count.errors %}
                                <div class="text-danger">{{ form.count.errors }}</div>
                                {% endif %}
                            </div>
                            
                            <div class="mb-3">
                                <label for="{{ form.score.id_for_label }}" class="form-label">综合评分</label>
                                {{ form.score }}
                                {% if form.score.errors %}
                                <div class="text-danger">{{ form.score.errors }}</div>
                                {% endif %}
                            </div>
                        </div>
                        
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="{{ form.car_review_count.id_for_label }}" class="form-label">用户点评数量</label>
                                {{ form.car_review_count }}
                                {% if form.car_review_count.errors %}
                                <div class="text-danger">{{ form.car_review_count.errors }}</div>
                                {% endif %}
                            </div>
                            
                            <div class="mb-3">
                                <label for="{{ form.descender_price.id_for_label }}" class="form-label">降价幅度（万元）</label>
                                {{ form.descender_price }}
                                {% if form.descender_price.errors %}
                                <div class="text-danger">{{ form.descender_price.errors }}</div>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.series_pic_count.id_for_label }}" class="form-label">车系图片数量</label>
                        {{ form.series_pic_count }}
                        {% if form.series_pic_count.errors %}
                        <div class="text-danger">{{ form.series_pic_count.errors }}</div>
                        {% endif %}
                    </div>
                </div>
            </div>
            
            <hr>
            
            <div class="d-flex justify-content-between">
                <a href="{% url 'car_list' %}" class="btn btn-outline-secondary">
                    <i class="fas fa-times me-1"></i> 取消
                </a>
                <button type="submit" class="btn btn-primary">
                    <i class="fas fa-save me-1"></i> 保存车型信息
                </button>
            </div>
        </form>
    </div>
</div>
{% endblock %} 